package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.CustomerDailyAnalysis;
import com.pgybook.db.entity.domain.CustomerDailyAnalysisEx;
import com.pgybook.db.entity.domain.CustomerDailyAnalysisKey;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Repository
public interface CustomerDailyAnalysisMapper {
    int countByExample(CustomerDailyAnalysisEx example);

    int deleteByExample(CustomerDailyAnalysisEx example);

    @Delete({
            "delete from customerdailyanalysis",
            "where BZDAY = #{bzday,jdbcType=DATE}",
            "and LIBID = #{libid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(CustomerDailyAnalysisKey key);

    @Insert({
            "insert into customerdailyanalysis (BZDAY, LIBID, ",
            "CUSTGRADEID, NEWMEMBER, ",
            "LOSTMEMBER, UPGRADE, ",
            "NEWCUSTGRADEID)",
            "values (#{bzday,jdbcType=DATE}, #{libid,jdbcType=INTEGER}, ",
            "#{custgradeid,jdbcType=INTEGER}, #{newmember,jdbcType=INTEGER}, ",
            "#{lostmember,jdbcType=INTEGER}, #{upgrade,jdbcType=INTEGER}, ",
            "#{newcustgradeid,jdbcType=INTEGER})"
    })
    int insert(CustomerDailyAnalysis record);

    int insertSelective(CustomerDailyAnalysis record);

    List<CustomerDailyAnalysis> selectByExample(CustomerDailyAnalysisEx example);

    @Select({
            "select",
            "BZDAY, LIBID, CUSTGRADEID, NEWMEMBER, LOSTMEMBER, UPGRADE, NEWCUSTGRADEID",
            "from customerdailyanalysis",
            "where BZDAY = #{bzday,jdbcType=DATE}",
            "and LIBID = #{libid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CustomerDailyAnalysis selectByPrimaryKey(CustomerDailyAnalysisKey key);

    int updateByExampleSelective(@Param("record") CustomerDailyAnalysis record, @Param("example") CustomerDailyAnalysisEx example);

    int updateByExample(@Param("record") CustomerDailyAnalysis record, @Param("example") CustomerDailyAnalysisEx example);

    int updateByPrimaryKeySelective(CustomerDailyAnalysis record);

    @Update({
            "update customerdailyanalysis",
            "set CUSTGRADEID = #{custgradeid,jdbcType=INTEGER},",
            "NEWMEMBER = #{newmember,jdbcType=INTEGER},",
            "LOSTMEMBER = #{lostmember,jdbcType=INTEGER},",
            "UPGRADE = #{upgrade,jdbcType=INTEGER},",
            "NEWCUSTGRADEID = #{newcustgradeid,jdbcType=INTEGER}",
            "where BZDAY = #{bzday,jdbcType=DATE}",
            "and LIBID = #{libid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CustomerDailyAnalysis record);
}
